﻿using System;
using System.Data.Linq.Mapping;
using System.Collections.Generic;

using LeanEngine.Entity;
using LeanEngine.Validation;
using LeanEngine.Collections;
using LeanEngine.Data.Linq.Mapping;

namespace LeanEngine.Business.Security.Entity
{
    /// <summary>
    /// Represents a profile of an application user.
    /// </summary>
    [Serializable]
    [Table(Name = "UserProfile")]
    public class UserProfile : ChangeTrackerEntity
    {
        /// <summary>
        /// Initializes a new instance of LeanEngine.Business.Security.TransferObject.UserProfile class.
        /// </summary>
        public UserProfile()
        {
            ApplicationMethods = new ChangeTrackerCollection<ApplicationMethod>();
        }

        /// <summary>
        /// Gets or sets the identification of the user profile.
        /// </summary>
        [Column(Name = "ProfileID", IsPrimaryKey = true, IsDbGenerated = true)]
        public int ID
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the name of the user profile.
        /// </summary>
        [Column(Name = "ProfileName")]
        [IsNotEmpty(typeof(Resource.ErrorMessages), "UserProfileNameRequired")]
        public string Name
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the description of the user profile.
        /// </summary>
        [Column(Name = "Description")]
        public string Description
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the list of methods that can be accessed by this profile.
        /// </summary>
        [AssociationTable(Name = "FuncionalityAccessible")]
        [IsNotEmptyList(typeof(Resource.ErrorMessages), "UserProfileMethodListRequired")]
        public ChangeTrackerCollection<ApplicationMethod> ApplicationMethods
        {
            get;
            private set;
        }
    }
}
